<?php

    require_once('DAL/DA_Canciones.php');
    require_once('BE/BECancion.php');
    $id = "--Nuevo--";
    if(isset ($_SERVER['REMOTE_USER'])) $username = $_SERVER['REMOTE_USER'];
    else $username = "developer";

    if (isset ($_GET["id"])){
        if ($_GET["id"]>0){
            $id = $_GET["id"];
            $cancion = DA_Canciones::obtenerCancion($id);
        } else {
            $cancion = new BECancion();
        }
    }
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title><?php echo htmlspecialchars($cancion->titulo);?></title>
        <link rel="stylesheet" type="text/css" href="css/style.css" />
        <script type="text/javascript" src="js/jquery-1.4.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function(){
                hiddenFields();
                
                $('body').click(function(){
                   $('.divMessageZone').fadeOut(500);
                });

                if ($('#divMessage').html()!=''){
                   $('.divMessageZone').fadeIn(500);
                }

            });

            function hiddenFields(){
                $('.divMessageZone').hide();
            }

        </script>
    </head>
    <body>
        <div id="divMessageZone" class="divMessageZone">
            <span class="divMessage" id="divMessage">
                <?php
                    if(isset($_REQUEST['msg'])){
                        if($_REQUEST['msg']=='saved'){
                            echo "Mensaje no definido...";
                        }
                    }
                ?>
            </span>
        </div>
        <div>
            <h1><?php echo htmlspecialchars_decode($cancion->titulo);?> (<?php echo $id;?>) (<?php echo $username ;?>)</h1>
        </div>
        <div class="divCancion">
            <fieldset>
                <legend>Introducción</legend>
                <p style="font-family:'Courier New',Courier,monospace;font-size:1em;"><?php echo str_ireplace("\n", "<br />", str_ireplace(" ", "&nbsp;", htmlspecialchars($cancion->introduccion))); ?></p>
            </fieldset><br />
        </div>

        <div class="divCancion">
            <fieldset>
                <legend>Canción y Notas </legend>
            <p style="font-family:'Courier New',Courier,monospace;font-size:1em;"><?php echo str_ireplace("\n", "<br />", str_ireplace(" ", "&nbsp;", htmlspecialchars($cancion->cancion_y_notas))); ?></p>
            </fieldset><br />
        </div>
        <div class="divCreditos">
            <fieldset>
                <legend>Creditos y Observaciones</legend>
            <p style="font-family:'Courier New',Courier,monospace;font-size:1em;"><?php echo str_ireplace("\n", "<br />", htmlspecialchars($cancion->creditos)); ?></p>
            </fieldset>
        </div>
    </body>
</html>
